#ifndef __M_CONSUMER_H__
#define __M_CONSUMER_H__
#include "../mqcommon/mq_logger.hpp"
#include "../mqcommon/mq_helper.hpp"
#include "../mqcommon/mq_msg.pb.h"
#include <iostream>

namespace mymq
{
    // 消费者收到消息后调用回调函数处理，消费者标识-消息属性-消息主体
    using ConsumerCallback = std::function<void(const std::string, const BasicProperties* bp, const std::string)>;
    struct Consumer
    {
        using ptr = std::shared_ptr<Consumer>;
        std::string tag; // 消费者标识
        std::string qname; // 消费者订阅的队列名称
        bool auto_ack; // 是否自动确认标识
        ConsumerCallback callback;

        Consumer()
        {
            DLOG("new consumer %p", this);
        }
        Consumer(const std::string& ctag, const std::string& queue_name, bool ack_tag, 
            const ConsumerCallback& cb)
        : tag(ctag), qname(queue_name), auto_ack(ack_tag), callback(cb)
        {
            DLOG("new consumer %p", this);
        }
        ~Consumer()
        {
            DLOG("del consumer %p", this);
        }
    };
}
#endif